﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
    <head>
        <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
        <meta content="history" name="save">
        <title>SA1308: VariableNamesMustNotBePrefixed</title>
        <link rel="stylesheet" type="text/css" href="stylesheets/helpstudio.css"><link rel="stylesheet" type="text/css" href="styles/Presentation.css">
        <script src="script/helpstudio.js" type="text/javascript"></script>
        <script src="script/StandardText.js" type="text/jscript"></script>
    </head>
    <body id="hsbody">
        <input type="hidden" id="userDataCache" class="userDataStyle" name="userDataCache" />
        <div id="allHistory" class="saveHistory" onsave="saveScrollPosition()" onload="loadScrollPosition()"></div>
        <script type="text/jscript">WritePageTop(document.title);</script>
        <div id="pagebody">
            <div id="mainbody">
                <table>
                    <col />
                    <tr><td><p>TypeName</p></td><td><p>VariableNamesMustNotBePrefixed</p></td></tr>
                    <tr><td><p>CheckId</p></td><td><p>SA1308</p></td></tr>
                    <tr><td><p>Category</p></td><td><p>Naming Rules</p></td></tr>
                </table>           
                <h2>Cause</h2>
                <P>A field name in C# is prefixed with <EM>m_</EM> or <EM>s_</EM>.</P>
                <H2>Rule Description</H2>
                <P>A violation of this rule occurs when a field name is prefixed by <EM>m_</EM> or <EM>s_</EM>.</P>
                <P>By default, StyleCop disallows the use of underscores, <EM>m_</EM>, etc., to mark local class fields, in favor of the ‘this.’ prefix. The advantage of using ‘this.’ is that it applies equally to all element types including methods, properties, etc., and not just fields, making all calls to class members instantly recognizable, regardless of which editor is being used to view the code. Another advantage is that it creates a quick, recognizable differentiation between instance members and static members, which will not be prefixed.</P>
                <P>If the field or variable name is intended to match the name of an item associated with Win32 or COM, and thus needs to begin with the prefix, place the field or variable within a special <EM>NativeMethods</EM> class. A NativeMethods class is any class which contains a name ending in NativeMethods, and is intended as a placeholder for Win32 or COM wrappers. StyleCop will ignore this violation if the item is placed within a NativeMethods class.</P>
                <H2>How to Fix Violations</H2>
                <P>To fix a violation of this rule, remove the prefix from the beginning of the field name, or place the item within a NativeMethods class if appropriate.</P>
            <h2>How to Suppress Violations</h2>
                <pre>[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1308:VariableNamesMustNotBePrefixed", Justification = "Reviewed.")]</pre>
            </div>
            <script type="text/jscript">WritePageFooter();</script>   
        </div>
    </body>
</html>